package com.eascs.workflow.dictionary.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.eascs.common.util.StringUtil;
import com.eascs.site.tag.select.SelectDataService;
import com.eascs.workflow.common.dao.BaseDao;

@Service
public class SelectDataServiceImpl extends BaseDao implements SelectDataService {
	@Override
	public List<Object[]> getDataSouce(String dataSouceType, String dataSouceFrom) {
		List<Object[]> dataSouceList = new ArrayList<>();
		StringBuffer sql = new StringBuffer("select d.`code`,d.`name` from wf_dictionary_data d ,"
				+ "wf_dictionary_type t where t.id = d.type and t.is_lock='N' and d.is_lock = 'N' and t.type= ? ");
		if (StringUtil.isNotBlank(dataSouceFrom)) {
			sql.append(" and d.`code` = ?");
			dataSouceList = workflowJdbcSession.findObjectsList(sql.toString(), dataSouceType, dataSouceFrom);
		} else {
			dataSouceList = workflowJdbcSession.findObjectsList(sql.toString(), dataSouceType);
		}
		return dataSouceList;
	}

}
